﻿using System.Web.Routing;

namespace OpusSuite.Globalisation
{
    public class GlobalisedRoute : Route
    {
        
        public const string CultureKey = "culture";

        static string CreateCultureRoute(string unGlobalisedUrl)
        {
            return string.Format("{{" + CultureKey + "}}/{0}", unGlobalisedUrl);
        }

        public GlobalisedRoute(string unGlobalisedUrl, RouteValueDictionary defaults) :
            base(CreateCultureRoute(unGlobalisedUrl),
                    defaults,
                    new RouteValueDictionary(new { culture = new CultureRouteConstraint() }),
                    new GlobalisationRouteHandler())
        {
        }
    }
}
